package org.zuel.lkq.util;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zuel.lkq.domain.User;

public class MySecurityUtil {

    private static Logger logger = LoggerFactory.getLogger(MySecurityUtil.class);

    public static User getCurrentUser() {
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        user.setPassword(null);
        return user;
    }

    public static Integer getCurrentUserId() {
        return getCurrentUser().getId();
    }

    public static String getCurrentUsername() {
        return getCurrentUser().getUsername();
    }

}
